let requestObj = {
  params: '',
  goodlist: '/api/1.0/h5/lottery/getLottery?back=',
  gain: '/api/1.0/h5/lottery/gain?back=',
  summary: '/api/1.0/h5/lottery/rewardClick?back=',
  moreGame: '/api/1.0/h5/lottery/getSupplyLottery?back=',
  init: function() {
    this.getParams();
  },
  // get params
	getQueryString: function(url, name) {
    const reg = new RegExp('(^|\\?|&)' + name + '=([^&#]*)(\\s|&|#|$)','i');
    if(reg.test(url)) return RegExp.$2.replace(/\+/g, ' ');
  },
  getParams: function() {
    this.params = this.getQueryString(window.location.href, 'back');
  },
  getHost: function() {
    return '//game.adbaitai.com';
  },
  getGoodsList: function(callback) {
    let _url = this.getHost() + this.goodlist + this.params;
    this.ajaxRequest(_url, function(data){
      callback && callback(data);
    });
  },
  getGood: function(callback) {
    let _url = this.getHost() + this.gain + this.params;
    this.ajaxRequest(_url, function(data){
      callback && callback(data);
    });
  },
  getMoreGame: function(callback) {
    let _url = this.getHost() + this.moreGame + this.params;
    this.ajaxRequest(_url, function(data){
      callback && callback(data);
    });
  },
  doSummary: function() {
    let _url = this.getHost() + this.summary + this.params;
    this.ajaxRequest(_url, function(data){

    });
  },
  ajaxRequest: function(url, callback) {
    $.ajax({
      url: url,
      dataType: 'jsonp',
      success: function(data) {
        callback && callback(data);
      }
    });
  }
}
requestObj.init();
module.exports = requestObj;
